import Cookie from 'js-cookie'
export default function ({store, route, redirect, from, error}) {
  if (route != null && (route.name === 'index' || route.name === 'category-id')) {
    store.dispatch('setCurrentRoute', {currentRoute: 'index'})
    if (route.name === 'index') {
      store.dispatch('setCategory', {category: '0'})
    } else {
      store.dispatch('setCategory', {category: route.params.id})
    }
  } else {
    if (route.name === 'find-index-id') {
      if (route.params.id !== '2') {
        store.dispatch('setFindRouteParam', {findRouteParam: 'findindex'})
      } else {
        store.dispatch('setFindRouteParam', {findRouteParam: 'unfindindex'})
      }
    }
    if (route.name === 'my-index-id') {
      if (route.params.id === '4' || route.params.id === undefined) {
        store.dispatch('setMyRouteParam', {myRouteParam: 'myindex'})
      } else {
        store.dispatch('setMyRouteParam', {myRouteParam: 'unmyindex'})
      }
    }
    store.dispatch('setCurrentRoute', {currentRoute: route.name})
  }
}
